﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DataAccess;
namespace SQT.tracnghiem.Ajax.ASP.Notification
{
    public partial class notification_edit_form : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        public bool check_accept(int id, string role)
        {
            if (!String.IsNullOrEmpty(role))
            {
                string[] split = role.Split(',');
                for (int i = 0; i < split.Length - 1; i++)
                {
                    if (id == int.Parse(split[i]))
                    {
                        return true;
                    }
                }
            }
            return false;
        }

        public bool check_full_acceot(int role, string accept)
        {
            bool check = true;
            string[] split = accept.Split(',');
            var get_manager = new TblManagerController().FetchAll().Where(x => x.Role == role && x.Active == true);
            foreach (TblManager manager in get_manager)
            {
                bool temp = false;
                for (int i = 0; i < split.Length - 1; i++)
                {
                    if (manager.ManagerId == int.Parse(split[i]))
                    {
                        temp = true;
                        break;
                    }

                }
                if (temp == false)
                {
                    check = false;
                    break;
                }
            }
            return check;
        }
    }
}